local function getTime()
    -- return os.time()
    return os.clock()
end

local function test_reactive()
    local obj = Core.Reactive({name = "Jason", age = 17})
    obj:subscribe("age", function (newValue, oldValue)
        print("===>Test: Reactive change age", oldValue, "to", newValue)
    end)
    obj.age = 18
end

local function test_reactive_1()
    local N = 100 * 10000 -- 不带print差不多上限了 0.325s左右
    -- local N = 10000 -- 带print差不多上限了 0.8s左右
    local dList = {}

    local t = getTime()

    for i = 1, N do
        local obj = Core.Reactive({ name = "Jason", age = i + 13, value = i})
        obj:subscribe("value", function (newValue, oldValue)
            -- print(oldValue, newValue)
        end)
        dList[#dList + 1] = obj
    end

    local t1 = getTime()
    print("---dt1", t1 - t)

    for i, v in ipairs(dList) do
        if i % 2 == 0 then
            v.value = i / 2
        end
    end

    local t2 = getTime()
    print("---dt2", t2 - t1)
end

return function()
    print("===>Test: lua_reactive")
    -- test_reactive()
    test_reactive_1()
end